package test;

import freemarker.template.*;
import java.util.*;
import java.io.*;
import java.util.logging.Level;
import java.util.logging.Logger;

public class NewClass {

  

    public static void main(String[] args) {
        try {
            /* ------------------------------------------------------------------- */
            /* You should do this ONLY ONCE in the whole application life-cycle:   */

            /* Create and adjust the configuration */
            Configuration cfg = new Configuration();
            cfg.setDirectoryForTemplateLoading(
                    new File("templates"));
            cfg.setObjectWrapper(new DefaultObjectWrapper());

            /* ------------------------------------------------------------------- */
            /* You usually do these for many times in the application life-cycle:  */

            /* Get or create a template */
            Template temp = cfg.getTemplate("war\\EntityManagers\\EntityManageFacadeLocal.ftl");

            /* Create a data-model */

            List<Map> objects=new ArrayList<Map>();
            
            Map<String,Object> root = new HashMap<String,Object>();
            Map<String,Object> m2 = new HashMap<String,Object>();
            
            m2.put("test", "00000");
            objects.add(m2);
            
            m2=new HashMap<String, Object>();
            m2.put("test", "222222333333");
            objects.add(m2);
            
            root.put("user", "Big Joe");
            root.put("listoo", objects);
            
           
     
            /* Merge data-model with template */
            //        Writer out = new OutputStreamWriter(System.out);
            Writer out = new PrintWriter(new File("d:\\test1.txt"));
            temp.process(root, out);
            out.flush();
        } catch (TemplateException ex) {
            Logger.getLogger(NewClass.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(NewClass.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
